package com.baidu.mapapi;

import android.content.Context;
import android.location.GpsSatellite;
import android.location.GpsStatus;
import android.location.GpsStatus.Listener;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.wifi.ScanResult;
import android.os.Bundle;
import android.telephony.NeighboringCellInfo;
import java.util.Iterator;
import java.util.List;

class e
{
  Location a;
  private LocationManager b = null;
  private LocationListener c = null;
  private Context d;
  private a e;
  private int f;
  private GpsStatus g;

  public e(Context paramContext)
  {
    this.a = null;
    this.e = null;
    this.f = 0;
    this.d = paramContext;
  }

  String a(int paramInt1, int paramInt2, int paramInt3, int paramInt4, List<NeighboringCellInfo> paramList, String paramString)
  {
    String str = null;
    if ((paramInt3 == 0) || (paramInt4 == 0));
    while (true)
    {
      return str;
      Object[] arrayOfObject = new Object[4];
      arrayOfObject[0] = Integer.valueOf(paramInt1);
      arrayOfObject[1] = Integer.valueOf(paramInt2);
      arrayOfObject[2] = Integer.valueOf(paramInt3);
      arrayOfObject[3] = Integer.valueOf(paramInt4);
      str = paramString.concat(String.format("%d|%d|%d|%d", arrayOfObject));
    }
  }

  public String a(List<ScanResult> paramList, String paramString)
  {
    String str2;
    int i = paramList.size();
    if (paramList.size() > 3)
      i = 3;
    String str1 = "";
    int j = 0;
    if (j < i)
      if (j == 0)
      {
        if (((ScanResult)paramList.get(j)).level == 0)
        {
          str2 = str1;
          return str2;
        }
        String str4 = str1.concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
        int l = ((ScanResult)paramList.get(j)).level;
        Object[] arrayOfObject2 = new Object[1];
        arrayOfObject2[0] = Integer.valueOf(l);
        str1 = str4.concat(String.format(";%d;", arrayOfObject2)).concat(((ScanResult)paramList.get(j)).SSID);
      }
    while (true)
    {
      while (true)
      {
        while (true)
          ++j;
        if (((ScanResult)paramList.get(j)).level != 0)
          break;
        str2 = str1;
      }
      String str3 = str1.concat("|").concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
      int k = ((ScanResult)paramList.get(j)).level;
      Object[] arrayOfObject1 = new Object[1];
      arrayOfObject1[0] = Integer.valueOf(k);
      str1 = str3.concat(String.format(";%d;", arrayOfObject1)).concat(((ScanResult)paramList.get(j)).SSID);
    }
  }

  void a()
  {
    if (this.d == null);
    while (true)
    {
      do
      {
        return;
        Mj.UpdataGPS(0D, 0D, 0F, 0F, 0F, 0);
        if (this.c == null)
          this.c = new LocationListener(this)
          {
            public void onLocationChanged()
            {
              int i;
              if (paramLocation != null)
              {
                Bundle localBundle = paramLocation.getExtras();
                if (localBundle == null)
                  break label77;
                i = localBundle.getInt("NumSatellite", 0);
              }
              while (true)
              {
                float f;
                if (paramLocation.hasAccuracy())
                  f = paramLocation.getAccuracy();
                while (true)
                {
                  Mj.UpdataGPS(paramLocation.getLongitude(), paramLocation.getLatitude(), (float)(3.6000000000000001D * paramLocation.getSpeed()), paramLocation.getBearing(), f, i);
                  this.a.a = paramLocation;
                  return;
                  f = 0F;
                }
                label77: i = 0;
              }
            }

            public void onProviderDisabled()
            {
              Mj.UpdataGPS(0D, 0D, 0F, 0F, 0F, 0);
              this.a.a = null;
            }

            public void onProviderEnabled()
            {
            }

            public void onStatusChanged(, int paramInt, Bundle paramBundle)
            {
              switch (paramInt)
              {
              default:
              case 0:
              case 1:
              }
              while (true)
              {
                return;
                Mj.UpdataGPS(0D, 0D, 0F, 0F, 0F, 0);
                this.a.a = null;
              }
            }
          };
        if (this.b == null)
          this.b = ((LocationManager)this.d.getSystemService("location"));
      }
      while (this.b == null);
      this.b.requestLocationUpdates("gps", 1000L, 0F, this.c);
      this.e = new a(this, null);
      this.b.addGpsStatusListener(this.e);
    }
  }

  public void a(int paramInt1, int paramInt2, long paramLong)
  {
    switch (paramInt1)
    {
    default:
    case 5000:
    }
    while (true)
    {
      while (true)
      {
        return;
        if (paramInt2 != 1)
          break;
        a();
      }
      b();
    }
  }

  public void a(List<ScanResult> paramList)
  {
    int i = paramList.size() - 1;
    for (int j = 1; (i >= 1) && (j != 0); j = l)
    {
      int k = 0;
      int l = 0;
      while (k < i)
      {
        if (((ScanResult)paramList.get(k)).level < ((ScanResult)paramList.get(k + 1)).level)
        {
          ScanResult localScanResult = (ScanResult)paramList.get(k + 1);
          paramList.set(k + 1, paramList.get(k));
          paramList.set(k, localScanResult);
          l = 1;
        }
        ++k;
      }
      --i;
    }
  }

  public boolean a(List<ScanResult> paramList1, List<ScanResult> paramList2)
  {
    int i;
    if (paramList1 == paramList2)
      i = 1;
    while (true)
    {
      while (true)
      {
        int j;
        int k;
        String str;
        while (true)
        {
          while (true)
          {
            return i;
            if ((paramList1 != null) && (paramList2 != null))
              break;
            i = 0;
          }
          j = paramList1.size();
          k = paramList2.size();
          if ((j != 0) && (k != 0))
            break;
          i = 0;
        }
        int l = 0;
        int i1 = 0;
        while (true)
        {
          if (l >= j)
            break label137;
          str = ((ScanResult)paramList1.get(l)).BSSID;
          if (str != null)
            break;
          ++l;
        }
        int i2 = 0;
        while (true)
        {
          while (true)
          {
            if (i2 >= k);
            if (!(str.equals(((ScanResult)paramList2.get(i2)).BSSID)))
              break;
            ++i1;
          }
          ++i2;
        }
        label137: if (i1 < j / 2)
          break;
        i = 1;
      }
      i = 0;
    }
  }

  public String b(List<ScanResult> paramList, String paramString)
  {
    String str2;
    int i = paramList.size();
    if (paramList.size() > 3)
      i = 3;
    String str1 = "";
    int j = 0;
    if (j < i)
      if (j == 0)
      {
        if (((ScanResult)paramList.get(j)).level == 0)
        {
          str2 = str1;
          return str2;
        }
        str1 = str1.concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
      }
    while (true)
    {
      while (true)
      {
        while (true)
          ++j;
        if (((ScanResult)paramList.get(j)).level != 0)
          break;
        str2 = str1;
      }
      str1 = str1.concat("|").concat(((ScanResult)paramList.get(j)).BSSID.replace(":", ""));
    }
  }

  void b()
  {
    if (this.b != null)
      this.b.removeUpdates(this.c);
    Mj.UpdataGPS(0D, 0D, 0F, 0F, 0F, 0);
  }

  private class a
  implements GpsStatus.Listener
  {
    public void onGpsStatusChanged()
    {
      int i;
      int j;
      switch (paramInt)
      {
      case 3:
      default:
        return;
      case 4:
        if (e.a(this.a) == null)
          e.a(this.a, (LocationManager)e.b(this.a).getSystemService("location"));
        if (e.a(this.a) != null)
        {
          if (e.c(this.a) != null)
            break label154;
          e.a(this.a, e.a(this.a).getGpsStatus(null));
        }
        Iterator localIterator = e.c(this.a).getSatellites().iterator();
        i = 0;
        if (!(localIterator.hasNext()))
          break label175;
        if (!(((GpsSatellite)localIterator.next()).usedInFix()))
          break label224;
        j = i + 1;
      case 2:
      }
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
                i = j;
              label154: e.a(this.a).getGpsStatus(e.c(this.a));
            }
            if ((i < 3) && (e.d(this.a) >= 3))
              label175: Mj.UpdataGPS(0D, 0D, 0F, 0F, 0F, 0);
            e.a(this.a, i);
          }
          Mj.UpdataGPS(0D, 0D, 0F, 0F, 0F, 0);
        }
        label224: j = i;
      }
    }
  }
}